package mr.ali.webvideo.controller;


import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import mr.ali.webvideo.Exception.R;
import mr.ali.webvideo.model.CollectionTags;
import mr.ali.webvideo.service.ICollectionTagsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Mr-ali
 * @since 2025-08-16
 */
@RestController
@RequestMapping("/h5/collectionTags")
@Slf4j
public class CollectionTagsController {

    @Resource
    private ICollectionTagsService collectionTagsService;
    /**
     * 首页面的通过电影标签获取video部分
     */
    @GetMapping("/all")
    public R<PageInfo<CollectionTags>> list(Integer pageNum, Integer pageSize , Integer sortId , Integer type) {
        if (pageNum == null || pageNum == 0) {
            pageNum = 1;
        } else if (pageSize == null || pageNum == 0) {
            pageSize = 9;
        }
        log.info("pageNum:{},pageSize:{},sortId:{},type:{}" , pageNum, pageSize,sortId , type );
        PageInfo<CollectionTags> videoList = collectionTagsService.videoTags(pageNum, pageSize, sortId , type );
        log.info("videoList:{}", videoList);
        log.info("videoListgetList():{}", videoList.getList());
        return R.ok(videoList);
    }

    @GetMapping("/sort")
    public PageInfo<CollectionTags> videoSortYearTypeAll(Integer pageNum, Integer pageSize, Integer sortId, Integer type, Integer yurt, String year) {
        if (pageNum == null || pageNum == 0) {
            pageNum = 1;
        } else if (pageSize == null || pageNum == 0) {
            pageSize = 12;
        }
        PageInfo<CollectionTags> videoList = collectionTagsService.videoSortYearTypeAll(pageNum, pageSize, sortId, type, yurt, year);
        return videoList;
    }
}
